stylecontext: Convert _gtk_style_context_peek_property()
authorBenjamin Otte <otte@redhat.com>
Sat, 31 Mar 2012 03:42:28 +0000 (05:42 +0200)
committerBenjamin Otte <otte@redhat.com>
Tue, 17 Apr 2012 06:59:15 +0000 (08:59 +0200)
Take the property id instead of the name.

12 files changed:
gtk/gtkborderimage.c
gtk/gtkcsscomputedvalues.c
gtk/gtkcssnumbervalue.c
gtk/gtkcssrgbavalue.c
gtk/gtkcssstylefuncs.c
gtk/gtkcssstylepropertyimpl.c
gtk/gtkcsstypes.c
gtk/gtkstylecontext.c
gtk/gtkstylecontextprivate.h
gtk/gtkthemingbackground.c
gtk/gtkthemingengine.c
gtk/gtkthemingengineprivate.h

index 399e869c4a92d667ac6c3fa980519211a1db2f1d..f13cc865256579d0a6f12e288cd1b321ade71936 100644 (file)
@@ -40,12 +40,12 @@ _gtk_border_image_init (GtkBorderImage   *image,
 {
   GtkBorder *width;
 
-  image->source = _gtk_css_image_value_get_image (_gtk_theming_engine_peek_property (engine, "border-image-source"));
+  image->source = _gtk_css_image_value_get_image (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE));
   if (image->source == NULL)
     return FALSE;
 
-  image->slice = *(GtkBorder *) _gtk_css_value_get_boxed (_gtk_theming_engine_peek_property (engine, "border-image-slice"));
-  width = _gtk_css_value_get_boxed (_gtk_theming_engine_peek_property (engine, "border-image-width"));
+  image->slice = *(GtkBorder *) _gtk_css_value_get_boxed (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_IMAGE_SLICE));
+  width = _gtk_css_value_get_boxed (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_IMAGE_WIDTH));
   if (width)
     {
       image->width = *width;
@@ -54,7 +54,7 @@ _gtk_border_image_init (GtkBorderImage   *image,
   else
     image->has_width = FALSE;
 
-  image->repeat = *_gtk_css_value_get_border_image_repeat (_gtk_theming_engine_peek_property (engine, "border-image-repeat"));
+  image->repeat = *_gtk_css_value_get_border_image_repeat (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_IMAGE_REPEAT));
 
   return TRUE;
 }
index 6b2ca8e8e955fb34d68259e8e6f0159bcba0e934..44a7f97e258e82986bbc2c43f6fa1481cc0e4d4e 100644 (file)
@@ -157,8 +157,7 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
     {
       GtkCssValue *parent_value;
       /* Set NULL here and do the inheritance upon lookup? */
-      parent_value = _gtk_style_context_peek_property (parent,
-                                                       _gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop)));
+      parent_value = _gtk_style_context_peek_property (parent, id);
 
       g_ptr_array_index (values->values, id) = _gtk_css_value_ref (parent_value);
     }
index 106fd76378eebe2d4ad29b331a90542cdcd86430..fded8c7df7544376db973b8e0e9367a92bfcad75 100644 (file)
@@ -189,13 +189,13 @@ _gtk_css_number_value_compute (GtkCssValue     *number,
       break;
     case GTK_CSS_EM:
       return _gtk_css_number_value_new (number->value *
-                                        _gtk_css_number_value_get (_gtk_style_context_peek_property (context, "font-size"), 100),
+                                        _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_FONT_SIZE), 100),
                                         GTK_CSS_PX);
       break;
     case GTK_CSS_EX:
       /* for now we pretend ex is half of em */
       return _gtk_css_number_value_new (number->value * 0.5 * 
-                                        _gtk_css_number_value_get (_gtk_style_context_peek_property (context, "font-size"), 100),
+                                        _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_FONT_SIZE), 100),
                                         GTK_CSS_PX);
     case GTK_CSS_RAD:
       return _gtk_css_number_value_new (number->value * 360.0 / (2 * G_PI),
index 61d8b1f8c5d0786ae442e3146760d21d3854fd05..490ca35f1298886b12aa521c8f1dd6aff098b8a4 100644 (file)
@@ -117,13 +117,13 @@ _gtk_css_rgba_value_compute_from_symbolic (GtkCssValue     *rgba,
           GtkStyleContext *parent = gtk_style_context_get_parent (context);
 
           if (parent)
-            return _gtk_css_value_ref (_gtk_style_context_peek_property (parent, "color"));
+            return _gtk_css_value_ref (_gtk_style_context_peek_property (parent, GTK_CSS_PROPERTY_COLOR));
           else
             return _gtk_css_rgba_value_compute_from_symbolic (fallback, NULL, context, TRUE);
         }
       else
         {
-          return _gtk_css_value_ref (_gtk_style_context_peek_property (context, "color"));
+          return _gtk_css_value_ref (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR));
         }
     }
   
index eaade29581085be53e62b853a30e8a0da9837960..518a32731e1bd96cd1f01edfc548abaf1d7f0550 100644 (file)
@@ -224,7 +224,7 @@ rgba_value_compute (GtkStyleContext *context,
       GdkRGBA rgba;
 
       if (symbolic == _gtk_symbolic_color_get_current_color ())
-        rgba = *_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, "color"));
+        rgba = *_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR));
       else if (!gtk_symbolic_color_resolve (symbolic, NULL, &rgba))
         rgba = white;
 
index e3abc7c7e9c86888a0564f0ac753e570c56553e2..b2ee619d54c329cd88847d73a4677a07dabc2f89 100644 (file)
@@ -834,15 +834,12 @@ compute_border_width (GtkCssStyleProperty    *property,
                       GtkStyleContext        *context,
                       GtkCssValue            *specified)
 {
-  GtkCssStyleProperty *style;
   GtkBorderStyle border_style;
   
   /* The -1 is magic that is only true because we register the style
    * properties directly after the width properties.
    */
-  style = _gtk_css_style_property_lookup_by_id (_gtk_css_style_property_get_id (property) - 1);
-  
-  border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, _gtk_style_property_get_name (GTK_STYLE_PROPERTY (style))));
+  border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, _gtk_css_style_property_get_id (property) - 1));
 
   if (border_style == GTK_BORDER_STYLE_NONE ||
       border_style == GTK_BORDER_STYLE_HIDDEN)
index 411f401693d34190626f53379121854c2efb6075..640ab3170957597d80c4ba6ed0200c1e776e1fe8 100644 (file)
@@ -158,12 +158,12 @@ _gtk_css_number_compute (GtkCssNumber       *dest,
       dest->unit = GTK_CSS_PX;
       break;
     case GTK_CSS_EM:
-      dest->value = src->value * _gtk_css_number_value_get (_gtk_style_context_peek_property (context, "font-size"), 100);
+      dest->value = src->value * _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_FONT_SIZE), 100);
       dest->unit = GTK_CSS_PX;
       break;
     case GTK_CSS_EX:
       /* for now we pretend ex is half of em */
-      dest->value = src->value * _gtk_css_number_value_get (_gtk_style_context_peek_property (context, "font-size"), 100);
+      dest->value = src->value * _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_FONT_SIZE), 100);
       dest->unit = GTK_CSS_PX;
       break;
     case GTK_CSS_RAD:
index 218df50eecb931c9256a9b4fc189b64fc4790883..9b86904c1b7628036a0e4b748c8e7a819b45a37e 100644 (file)
@@ -2241,21 +2241,21 @@ style_property_values_cmp (gconstpointer bsearch_node1,
 
 GtkCssValue *
 _gtk_style_context_peek_property (GtkStyleContext *context,
-                                  const char      *property_name)
+                                  guint            property_id)
 {
   StyleData *data = style_data_lookup (context);
 
-  return _gtk_css_computed_values_get_value_by_name (data->store, property_name);
+  return _gtk_css_computed_values_get_value (data->store, property_id);
 }
 
 double
 _gtk_style_context_get_number (GtkStyleContext *context,
-                               const char      *property_name,
+                               guint            property_id,
                                double           one_hundred_percent)
 {
   GtkCssValue *value;
   
-  value = _gtk_style_context_peek_property (context, property_name);
+  value = _gtk_style_context_peek_property (context, property_id);
   return _gtk_css_number_value_get (value, one_hundred_percent);
 }
 
index 759929ec628f6a85af9ad22ec1443146672e0194..9feaf78fb38f32f67467c64ba9a0f011c9bb8e67 100644 (file)
@@ -27,9 +27,9 @@ G_BEGIN_DECLS
 void            _gtk_style_context_set_widget                (GtkStyleContext *context,
                                                               GtkWidget       *widget);
 GtkCssValue   * _gtk_style_context_peek_property             (GtkStyleContext *context,
-                                                              const char      *property_name);
+                                                              guint            property_id);
 double         _gtk_style_context_get_number                 (GtkStyleContext *context,
-                                                              const char      *property_name,
+                                                              guint            property_id,
                                                               double           one_hundred_percent);
 const GValue * _gtk_style_context_peek_style_property        (GtkStyleContext *context,
                                                               GType            widget_type,
index 882e4969fe38944dc2d18890206e554bf36c1393..f6ae1d59184a1b4ad9e5d626b8bb328c9b8483fb 100644 (file)
@@ -55,7 +55,7 @@ _gtk_theming_background_apply_origin (GtkThemingBackground *bg)
   GtkCssArea origin;
   cairo_rectangle_t image_rect;
 
-  origin = _gtk_css_area_value_get (_gtk_style_context_peek_property (bg->context, "background-clip"));
+  origin = _gtk_css_area_value_get (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_CLIP));
 
   /* The default size of the background image depends on the
      background-origin value as this affects the top left
@@ -90,7 +90,7 @@ _gtk_theming_background_apply_origin (GtkThemingBackground *bg)
 static void
 _gtk_theming_background_apply_clip (GtkThemingBackground *bg)
 {
-  GtkCssArea clip = _gtk_css_area_value_get (_gtk_style_context_peek_property (bg->context, "background-clip"));
+  GtkCssArea clip = _gtk_css_area_value_get (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_CLIP));
 
   if (clip == GTK_CSS_AREA_PADDING_BOX)
     {
@@ -163,8 +163,8 @@ _gtk_theming_background_paint (GtkThemingBackground *bg,
       double image_width, image_height;
       double width, height;
 
-      size = _gtk_css_value_get_background_size (_gtk_style_context_peek_property (bg->context, "background-size"));
-      pos = _gtk_css_value_get_background_position (_gtk_style_context_peek_property (bg->context, "background-position"));
+      size = _gtk_css_value_get_background_size (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_SIZE));
+      pos = _gtk_css_value_get_background_position (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_POSITION));
       gtk_style_context_get (bg->context, bg->flags,
                              "background-repeat", &hrepeat,
                              NULL);
@@ -298,7 +298,7 @@ static void
 _gtk_theming_background_apply_shadow (GtkThemingBackground *bg,
                                       cairo_t              *cr)
 {
-  _gtk_css_shadow_value_paint_box (_gtk_style_context_peek_property (bg->context, "box-shadow"),
+  _gtk_css_shadow_value_paint_box (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BOX_SHADOW),
                                    cr,
                                    &bg->padding_box);
 }
@@ -332,7 +332,7 @@ _gtk_theming_background_init_context (GtkThemingBackground *bg)
   _gtk_theming_background_apply_clip (bg);
   _gtk_theming_background_apply_origin (bg);
 
-  bg->image = _gtk_css_image_value_get_image (_gtk_style_context_peek_property (bg->context, "background-image"));
+  bg->image = _gtk_css_image_value_get_image (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_IMAGE));
 }
 
 void
index aad10aca5722eee21c497fbb156c74174f9e7746..8ce1727837bb52f6566a11786655e01f7a203a53 100644 (file)
@@ -342,23 +342,21 @@ _gtk_theming_engine_get_context (GtkThemingEngine *engine)
 
 GtkCssValue *
 _gtk_theming_engine_peek_property (GtkThemingEngine *engine,
-                                   const char       *property_name)
+                                   guint             property_id)
 {
   g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL);
-  g_return_val_if_fail (property_name != NULL, NULL);
 
-  return _gtk_style_context_peek_property (engine->priv->context, property_name);
+  return _gtk_style_context_peek_property (engine->priv->context, property_id);
 }
 
 double
 _gtk_theming_engine_get_number (GtkThemingEngine *engine,
-                                const char       *property_name,
+                                guint             property_id,
                                 double            one_hundred_percent)
 {
   g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), 0.0);
-  g_return_val_if_fail (property_name != NULL, 0.0);
 
-  return _gtk_style_context_get_number (engine->priv->context, property_name, one_hundred_percent);
+  return _gtk_style_context_get_number (engine->priv->context, property_id, one_hundred_percent);
 }
 
 /**
@@ -1822,17 +1820,17 @@ render_frame_internal (GtkThemingEngine *engine,
       render_border (cr, &border_box, &border, hidden_side, colors, border_style);
     }
 
-  border_style[0] = _gtk_css_border_style_value_get (_gtk_theming_engine_peek_property (engine, "outline-style"));
+  border_style[0] = _gtk_css_border_style_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_OUTLINE_STYLE));
   if (border_style[0] != GTK_BORDER_STYLE_NONE)
     {
       int offset;
 
       border_style[1] = border_style[2] = border_style[3] = border_style[0];
-      border.top = _gtk_css_value_get_int (_gtk_theming_engine_peek_property (engine, "outline-width"));
+      border.top = _gtk_css_value_get_int (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_OUTLINE_WIDTH));
       border.left = border.right = border.bottom = border.top;
-      colors[0] = *_gtk_css_rgba_value_get_rgba (_gtk_theming_engine_peek_property (engine, "outline-color"));
+      colors[0] = *_gtk_css_rgba_value_get_rgba (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_OUTLINE_COLOR));
       colors[3] = colors[2] = colors[1] = colors[0];
-      offset = _gtk_css_value_get_int (_gtk_theming_engine_peek_property (engine, "outline-offset"));
+      offset = _gtk_css_value_get_int (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_OUTLINE_OFFSET));
       
       /* reinit box here - outlines don't have a border radius */
       _gtk_rounded_box_init_rect (&border_box, x, y, width, height);
@@ -2134,7 +2132,7 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine,
       fg_color.alpha = CLAMP (fg_color.alpha + ((other_fg.alpha - fg_color.alpha) * progress), 0, 1);
     }
 
-  text_shadow = _gtk_theming_engine_peek_property (engine, "text-shadow");
+  text_shadow = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_TEXT_SHADOW);
 
   prepare_context_for_layout (cr, x, y, layout);
 
@@ -2765,7 +2763,7 @@ render_spinner (GtkThemingEngine *engine,
   radius = MIN (width / 2, height / 2);
 
   gtk_theming_engine_get_color (engine, state, &color);
-  shadow = _gtk_theming_engine_peek_property (engine, "icon-shadow");
+  shadow = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_ICON_SHADOW);
 
   cairo_save (cr);
   cairo_translate (cr, x + width / 2, y + height / 2);
@@ -2943,7 +2941,7 @@ gtk_theming_engine_render_icon (GtkThemingEngine *engine,
 
   gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
 
-  _gtk_css_shadow_value_paint_icon (_gtk_theming_engine_peek_property (engine, "icon-shadow"), cr);
+  _gtk_css_shadow_value_paint_icon (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_ICON_SHADOW), cr);
 
   cairo_paint (cr);
 
index 63d0cfab008e2f4465f71531001cf9cbf1df0d22..63079eeab98915ea783c572234018911b319c54d 100644 (file)
@@ -28,9 +28,9 @@ void _gtk_theming_engine_paint_spinner (cairo_t *cr,
                                         GdkRGBA *color);
 
 GtkCssValue  *_gtk_theming_engine_peek_property (GtkThemingEngine *engine,
-                                                 const char       *property_name);
+                                                 guint             property_id);
 double        _gtk_theming_engine_get_number    (GtkThemingEngine *engine,
-                                                 const char       *property_name,
+                                                 guint             property_id,
                                                  double            one_hundred_percent);
 void          _gtk_theming_engine_set_context   (GtkThemingEngine *engine,
                                                  GtkStyleContext  *context);